﻿/******************************************
 * 
 * @author Михаил Малых
 * http://vkontakte.ru/id504911
 * 
 * ISocial интерфейс для API ВКонтакте.
 * 
 * Классы "социализации" приложения
 * 
 * License:
 * Read License.txt
 */

using System.Windows.Threading;
using System.Collections.Generic;
using System.Xml.Linq;

namespace VKontakte
{
    public delegate void ApiCallBackHandler<TResponse>(TResponse response);

    /// <summary>
    /// Класс профиля пользователя
    /// </summary>
    public class Profile
    {
        public enum ESex
        {
            Male,
            Female
        }

        public string Id = null;
        public string FirstName = null;
        public string LastName = null;
        public string NickName = null;
        public string Domain = null;
        public string Photo = null;
        public ESex Sex = ESex.Male;
        public string BirthDate = null;
        public string City = null;
        public string Country = null;
        public string Timezone = null;
        public string PhotoMedium = null;
        public string PhotoBig = null;
        public bool HasMobile = false;
        public string Rate = null;
        public string Contacts = null;
        public string Education = null;
    }
    public class Record
    {
        public string Id { set; get; }
        public string Name { set; get; }
        public int Value { set; get; }
        public Record(string id, string name, int value)
        {
            Id = id;
            Name = name;
            Value = value;
        }
        public static int Compare(Record x, Record y)
        {
            return x.Value - y.Value;
        }
    }



    /// <summary>
    /// Интерфейс ISocial Описывает базовые методы, необходимые для "социализации" приложения
    /// </summary>
    public interface ISocial
    {
        string GetId();
        bool IsAppUser();
        void LoadProfile(Dispatcher dispatcher = null, ApiCallBackHandler<Profile> callBack = null, ApiCallBackHandler<XDocument> errorCallBack = null);
        bool IsProfileLoaded();
        Profile GetProfile();
        void GetPhotoUri(string id, Dispatcher dispatcher, ApiCallBackHandler<string> callBack, ApiCallBackHandler<XDocument> errorCallBack = null);

        void PutGlobalVar(int key, string value, Dispatcher dispatcher = null, ApiCallBackHandler<bool> callBack = null, ApiCallBackHandler<XDocument> errorCallBack = null);
        void GetGlobalVars(int key, Dispatcher dispatcher, int count = 1, ApiCallBackHandler<Dictionary<int, string>> callBack = null, ApiCallBackHandler<XDocument> errorCallBack = null);
        void PutUserVar(int key, string value, Dispatcher dispatcher = null, ApiCallBackHandler<bool> callBack = null, ApiCallBackHandler<XDocument> errorCallBack = null);
        void GetUserVars(int key, Dispatcher dispatcher, ApiCallBackHandler<Dictionary<int, string>> callBack, int count = 1, ApiCallBackHandler<XDocument> errorCallBack = null);

        void ShowInviteFriendBox();
    }
}
